class CustomersController < ApplicationController
  before_filter :find_customer,  :except => [:index, :new, :create]

  access_control do
    allow :team_leader
    allow :chief_of_staff
  end
  
  layout "gestion"
  # GET /customers
  def index
    @customers = Customer.all
  end

  # GET /customers/1
  def show
  end

  # GET /customers/new
  def new
    @customer = Customer.new
  end

  # GET /customers/1/edit
  def edit
  end

  # POST /customers
  def create
    @customer = Customer.new(params[:customer])

    if @customer.save
    	redirect_to(@customer)
      else
        render :action => "new" 
      end
  end

  # PUT /customers/1
  def update
    if @customer.update_attributes(params[:customer])
      redirect_to(@customer)
    else
      render :action => "edit"
    end
  end

  # DELETE /customers/1
  def destroy
    @customer.destroy
  end
  
private 
	def find_customer
		@customer = Customer.find(params[:id])  
	end 
end
